package pl.edu.wsinf.lukaszwalczak.emailclient.pojo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;

/*
 * To jest bedzie klasa modelu ze wzorca MVC która modeluje konto email,
 * ale na razie na to nie zwracaj uwagi. Ważne jest to że takie klasy bedziemy
 * umieszczać w pakiecie pojo, a klasy serwisow wykonujace operacje na bazie
 * w pakiecie serwice.
 */
@Entity
@Table(name = "mail_accounts")
public class Account implements Serializable {

    public enum IncomingProtocol {

        POP3, IMAP
    }

    public enum OutgoingProtocol {

        SMTP
    }

    public enum ServerAuth {

        NO_AUTH, SSLTLS, STARTTLS
    }
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Size(max = 255)
    private String emailAddress;
    @Size(max = 255)
    private String password;
    @Size(max = 255)
    private String userName;
    @Size(max = 200)
    private String incomingServer;
    private Integer incomingServerPort;
    @Enumerated(EnumType.STRING)
    private IncomingProtocol incomingServerProtocol;
    @Enumerated(EnumType.STRING)
    private ServerAuth incomingServerAuth;
    @Size(max = 200)
    private String outgoingServer;
    private Integer outgoingServerPort;
    @Enumerated(EnumType.STRING)
    private OutgoingProtocol outgoingServerProtocol;
    @Enumerated(EnumType.STRING)
    private ServerAuth outgoingServerAuth;
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime downloadDate;
    @OneToMany(mappedBy = "account", fetch = FetchType.EAGER)
    List<Folder> folders;

    public Long getId() {
        return id;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getIncomingServer() {
        return incomingServer;
    }

    public void setIncomingServer(String incomingServer) {
        this.incomingServer = incomingServer;
    }

    public Integer getIncomingServerPort() {
        return incomingServerPort;
    }

    public void setIncomingServerPort(Integer incomingServerPort) {
        this.incomingServerPort = incomingServerPort;
    }

    public IncomingProtocol getIncomingServerProtocol() {
        return incomingServerProtocol;
    }

    public void setIncomingServerProtocol(IncomingProtocol incomingServerProtocol) {
        this.incomingServerProtocol = incomingServerProtocol;
    }

    public ServerAuth getIncomingServerAuth() {
        return incomingServerAuth;
    }

    public void setIncomingServerAuth(ServerAuth incomingServerAuth) {
        this.incomingServerAuth = incomingServerAuth;
    }

    public String getOutgoingServer() {
        return outgoingServer;
    }

    public void setOutgoingServer(String outgoingServer) {
        this.outgoingServer = outgoingServer;
    }

    public Integer getOutgoingServerPort() {
        return outgoingServerPort;
    }

    public void setOutgoingServerPort(Integer outgoingServerPort) {
        this.outgoingServerPort = outgoingServerPort;
    }

    public OutgoingProtocol getOutgoingServerProtocol() {
        return outgoingServerProtocol;
    }

    public void setOutgoingServerProtocol(OutgoingProtocol outgoingServerProtocol) {
        this.outgoingServerProtocol = outgoingServerProtocol;
    }

    public ServerAuth getOutgoingServerAuth() {
        return outgoingServerAuth;
    }

    public void setOutgoingServerAuth(ServerAuth outgoingServerAuth) {
        this.outgoingServerAuth = outgoingServerAuth;
    }

    public DateTime getDownloadDate() {
        return downloadDate;
    }

    public void setDownloadDate(DateTime downloadDate) {
        this.downloadDate = downloadDate;
    }

    public List<Folder> getFolders() {
        return folders;
    }

    public void setFolders(List<Folder> folders) {
        this.folders = folders;
    }
}
